473,426 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

Swap image with check/uncheck of Radio Button

Hi,
I use a radio button form in which users can select a color by clicking
on a image.
I would like this image to change to another one when it's chosen.
(image with a "Chosen" Stamp in the middle)
Of course I like it to be restored if hte user select another color.

I've tried to add behaviour to the image (swap on click) and on the
button (onchange swap restore) but it doesn't work (hte image id
swapped and restored almost instantly).

Any ideas ?

Mathieu

Jan 8 '07 #1
4 11482
le***@attglobal.net wrote:
Hi,
I use a radio button form in which users can select a color by clicking
on a image.
I would like this image to change to another one when it's chosen.
(image with a "Chosen" Stamp in the middle)
Of course I like it to be restored if hte user select another color.

I've tried to add behaviour to the image (swap on click) and on the
button (onchange swap restore) but it doesn't work (hte image id
swapped and restored almost instantly).

Any ideas ?

Mathieu
<input ... onclick=
'if(this.checked)document.images["imageName"].src="chosen.img"'>
<input ... onclick=
'if(this.checked)document.images["originalImageName"].src="original.img"'>
Mick
Jan 8 '07 #2
<input ... onclick=
'if(this.checked)document.images["imageName"].src="chosen.img"'>
<input ... onclick=
'if(this.checked)document.images["originalImageName"].src="original.img"'>
Mick
Thank you Mick,

I have 10 radio buttons, i can paste copy ten times the code and be
careful or do a function:
onclick="changeimages("ImageName1")"
but how do transalte document.images["imageName"].src="chosen.img"' if
i use a java script function.
document.form['myRadioGroup
Name'].images["imageName"].src="chosen.img"' , it dosen't work.

I want to do a loop on every buttons with the image having a
Nameimage+i name.

mat

Jan 9 '07 #3
i did it !!!

function change(idgroupimage)
{
for(var i=1;i<3;i++)
{
if (i!=idgroupimage)
{
eval
('document.form1.nameimage'+i+'.src="Photos/GIF/nameimage'+i+'.gif"');
}
else eval
('document.form1.nameimage'+i+'.src="Photos/GIF/nameimage'+i+'_ok.gif"');
}
}

Jan 9 '07 #4
le***@attglobal.net wrote:
i did it !!!

function change(idgroupimage)
{
for(var i=1;i<3;i++)
{
if (i!=idgroupimage)
{
eval
('document.form1.nameimage'+i+'.src="Photos/GIF/nameimage'+i+'.gif"');
}
else eval
('document.form1.nameimage'+i+'.src="Photos/GIF/nameimage'+i+'_ok.gif"');
}
}
Why not:
function change(idgroupimage){
for(var i=1;i<3;i++){
document.images["nameimage"+i].src=
"Photos/GIF/nameimage"+i+(i!=idgroupimage?"_ok.gif":".gif");
}
}
?
Mick

Jan 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jawahar Rajan | last post by:
All, I am using a few Input type of "Image" instead of a classic submit button in a form to achieve various tasks for example image1 - add user image2 - modify user image3 - delete user...
6
by: Ken Loomis | last post by:
Hello: On a web page I check the value of a cookie and set one of two radio buttons accordingly. function setRadioForm() { var myCookie = document.cookie; var OpenOnly =...
1
by: Brian Genisio | last post by:
Hi all, I noticed that the image input type does not show up in the elements array (IE 6.0). <FORM name=myForm> <INPUT name=rads id=check1 type=radio value=val1> <INPUT name=rads id=check2...
2
by: broms10 | last post by:
I need help. I have a little button that says "next" below a big image, letīs call it "image1", when I press the button I want to swap the big image to "image2". And then if I press it again I...
5
by: kid | last post by:
Hi, I have 5 checkbox elements, i.e: ( 1 ) a ( 2 ) b ( 3 ) c ( 4 ) d ( Check/Uncheck all )
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
9
by: ameshkin | last post by:
Hi guys, I'm a pretty good PHP programmer, but when it comes to JS, I just dont understand it! But I really need to learn. I'm having trouble doing the simplest thing! When someone clicks...
13
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
1
by: Anuj | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.